﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ServiceDeskClient.ServiceDeskServiceReference;

namespace ServiceDeskClient
{
    /// <summary>
    /// Interaction logic for SelectStatusWindow.xaml
    /// </summary>
    public partial class SelectStatusWindow : Window
    {

        public SelectStatusWindow()
        {
            InitializeComponent();
            DataContext = Enum.GetValues(typeof(TaskStateDTO)).Cast<TaskStateDTO>()
                            .Select(state =>
                                new StatusItem(state, () => SelectStatus(state))).ToList();
                                
        }
        public void SelectStatus(TaskStateDTO state)
        {
            Result = state;
            DialogResult = true;
            Close();
        }
        public TaskStateDTO? Result;

        private class StatusItem
        {
            public StatusItem(TaskStateDTO state, Action a)
            {
                State = state;
                Name = MainWindow.Model.TaskItem.GetStatusName(state);
                SelectCommand = new MainWindow.Model.SimpleCommand(a);

            }


            public string Name { get; private set; }
            public ICommand SelectCommand { get; private set; }
            public readonly TaskStateDTO State;
        }
    }
}
